package processors;

import java.awt.Rectangle;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.ParameterBlock;

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;

public class XORProcessor extends Processor<PlanarImage, PlanarImage> {
    PlanarImage original;

    public XORProcessor(String pathToOriginal) {
    	//this.original = JAI.create("fileload", pathToOriginal);
        PlanarImage temp = JAI.create("fileload", pathToOriginal);
        Rectangle rectangle = new Rectangle(0,50, temp.getWidth(), temp.getHeight());
        original = PlanarImage.wrapRenderedImage((RenderedImage)temp.getAsBufferedImage(rectangle, temp.getColorModel()));
    }
    
    
    @Override
    public void process(PlanarImage image) {
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.addSource(original);
        setOutput(JAI.create("xor", pb));
        //JAI.create("filestore", JAI.create("xor", pb), "result_xor.jpg", "JPEG");
    }

}
